package com.wondersgroup.fjzlpt.org.dao.impl.jtqy;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONArray;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.wondersgroup.fjzlpt.org.dao.inter.jtqy.JmrqflgxDAO;
@Repository
public class JmrqflgxDAOImpl extends BaseJTDAOImpl implements JmrqflgxDAO {

	@Override
	@Autowired
	@Qualifier("TB_JTQY_JMRQFLGX")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}
	
	@Override
	public JSONArray queryList(Map<String, String> map) {
		JSONArray jsonArray = null;
		if(map!=null && map.size()>0){
			StringBuffer sql = new StringBuffer("select * from tb_jtqy_jmrqflgx  where 1=1 \n");
			List list = new ArrayList();
			if(!StringUtils.isEmpty((String)map.get("JMXXID")))
			{
				sql.append("and JMXXID=?");
				list.add(map.get("JMXXID"));
			}
			SQLBean sqlBean = new SQLBean(sql.toString(),list.toArray());
			jsonArray= super.queryList(sqlBean);
		}
		return jsonArray;
	}

	public JSONArray queryRqflByJMXXID(String JMXXID){
		StringBuffer sql = new StringBuffer("select RQFLID from tb_jtqy_jmrqflgx  where 1=1 and JMXXID=?\n");
		SQLBean sqlBean = new SQLBean(sql.toString(), new Object[]{JMXXID});
		return super.queryList(sqlBean);
	}

	@Override
	public void deleteRqflgxByCondition(Map map) {
		List list = new ArrayList();
		if(map.size()>0){
			StringBuilder sql = new StringBuilder("delete from ").append(this.tb.getTableName()).append(" where 1=1 \n");
			if(!StringUtils.isEmpty((String)map.get("JMXXID")))
			{
				sql.append(" and JMXXID=?");
				list.add(map.get("JMXXID"));
			}
			SQLBean sb = new SQLBean(sql.toString(), list.toArray());
			this.update(sb);
		}
	}

	public void deleteRqflgxByJmxxId(String JMXXID){
		StringBuilder sql = new StringBuilder("delete from ")
				.append(this.tb.getTableName()).append(" where 1=1 \n")
				.append("and JMXXID=?");
		SQLBean sb = new SQLBean(sql.toString(), new Object[]{JMXXID});
		this.update(sb);
	}
}
